const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const QrcodeWebpackPlugin = require("qrcode-dev-webpack-plugin");

module.exports = {
  entry: "./index.js",
  output: {
    filename: "[name].js",
    path: path.resolve(__dirname, "dist"),
  },
  devServer: {
    port: 3000,
    hot: true,
    headers: {
      "Access-control-allow-origin": "*",
    },
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./index.html",
    }),
    new ModuleFederationPlugin({
      filename: "subAppEntry", // 远端文件名
      name: "AppSub", // 远端应用名
      exposes: {
        "./SubAPP": "./bootstrap.js",
      },
      shared: {
        dayjs: { singleton: true },
      },
    }),
    new QrcodeWebpackPlugin(),
  ],
};
